package exp07gui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

class MyApp extends JFrame implements ActionListener{
    JButton btnEqual;
    JButton btnEqual2;

    MyApp() {
        super();
        this.setTitle("计算器");
        this.setSize(226, 319);
        this.setLayout(new FlowLayout());
        this.add(btnEqual = new JButton("EQUAL"));
        btnEqual.addActionListener(this);
        this.add(btnEqual2 = new JButton("EQUAL2"));
        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getSource()==btnEqual){
            System.out.println("btnEqual");;
            JOptionPane.showMessageDialog(null,"btnEqual clicked");
        }
    }
}

public class JFrameDemo2 {


    public static void main(String[] args) {
        // MyApp window=new MyApp();
        new MyApp();

    }


}